x86/debug: Make debugger_trap_entry() safe during early boot
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 4 Aug 2016 11:38:05 +0000 (12:38 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 4 Aug 2016 13:59:18 +0000 (14:59 +0100)
commite67f56bbeccbb2b3e1fbe605b83c08918f19bf7c
tree0327692cb6a386c2dcc3e23abd3ffde87ce87eb9
parent350bc1a9d4ebc03b18a43cdafcb626618caace55
x86/debug: Make debugger_trap_entry() safe during early boot

debugger_trap_entry() is reachable during early boot where its unconditional
use of current is unsafe.  Add a warning to the function to this effect.

Perform the vector check first, as this allows the compiler to elide the other
content from most of its callsites.  Check guest_mode(regs) before using
current, which makes the path safe on early boot.

While editing this area, drop DEBUGGER_trap_{entry,fatal}, as hiding a return
statement in a function-like macro is very antisocial programming; show the
real control flow at each of the callsites.  Finally, switch
debugger_trap_{entry,fatal} to having boolean return types, to match their
semantics.

No behavioural change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/traps.c
xen/include/asm-x86/debugger.h